namespace Collaboris.Saf.Actions.Moss.Tests.Generated
{
    using Engine.Report;

    using Entities;

    using Microsoft.SharePoint.Publishing;
    using Microsoft.VisualStudio.TestTools.UnitTesting;

    using Moss.Publishing;

    using Saf.Tests;

    using SharePoint.Moss.Publishing;
    using SharePoint.Wss.Files;

    /// <summary>
    /// This test was originally generated but has now been tested and verfiied by MJ
    /// </summary>
    [TestClass]
    public class SetWelcomePageTest
    {
        #region Public Methods

        [TestMethod]
        public void SetWelcomePage_Test()
        {
            var setwelcomepage = new TestAssistant<SetWelcomePage, SiteAndPage>(
                TestEnvironment.PublishingSite, "SetWelcomePageTestWeb", "BLANKINTERNET#0");

            using (setwelcomepage)
            {
                SPFileHelper.CopyFile(setwelcomepage.TestWeb.Url + @"/Pages/default.aspx", setwelcomepage.TestWeb.Url + @"/Pages/default2.aspx", true, false);

                PublishingWeb pubweb = PublishingWeb.GetPublishingWeb(setwelcomepage.TestWeb);
                setwelcomepage.FirstEntity.PageName = "default2.aspx";
                MacroReport doReport = setwelcomepage.DoMacro();
                
                PublishingPage page = PublishingPageHelper.GetDefaultPage(pubweb);
                Assert.IsTrue(page.Name.ToLower() == "default2.aspx");

                MacroReport unDoReport = setwelcomepage.UndoMacro();

                Assert.IsTrue(PublishingWeb.GetPublishingWeb(setwelcomepage.TestWeb).DefaultPage.Name.ToLower() == "default.aspx");

            }
        }

        #endregion
    }
}